from django import template
from django.utils.safestring import mark_safe

register = template.Library()  # register不能变


@register.filter
def new_upper(value, arg=None):
    print(arg)
    return value.upper()


@register.filter
def cheng(value, arg):
    try:
        value = int(value)
        arg = int(arg)

        return value * arg
    except Exception:
        return 'xx'


@register.filter
def show_a(url, name):
    return '<a href="http://{}">{}</a>'.format(url, name)


@register.simple_tag
def join_str(*args, **kwargs):
    return '_'.join(args) + "*".join(kwargs.values())


